<?php
/**
 * PsiFramework
 *
 * Php Simple Framework
 *
 * PHP version 5.3
 *
 * @category  PsiFramework.Plugins.CMS.Classes.Actions
 * @package   PsiFramework.Plugins.CMS.Classes.Actions
 * @author    Remi San <remi.san@gmail.com>
 * @copyright 2011 Remi San
 * @license   http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @version   SVN: <svn_id>
 * @link      http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins.CMS.Classes.Actions.EditAction.html
 */

namespace PsiFramework\Plugins\CMS\Classes\Actions;

import("Classes.Actions.AbstractAction");
import("Classes.Factory.DAOFactory");

use \PsiFramework\Classes\Actions\AbstractAction;
use \PsiFramework\Classes\Factory\DAOFactory;

/**
 * Default edit action
 * 
 * This is the default class for the ecit action.
 *
 * @category PsiFramework.Plugins.CMS.Classes.Actions
 * @package  PsiFramework.Plugins.CMS.Classes.Actions
 * @author   Remi San <remi.san@gmail.com>
 * @license  http://creativecommons.org/licenses/by/3.0/  Creative Commons CC BY 3.0
 * @link     http://www.psiframework.com/phpdoc/classes/db_\PsiFramework\Plugins.CMS.Classes.Actions.EditAction.html
 */
class EditAction extends AbstractAction
{

    /**
     * The main function of the method which is called every time
     * an action is created by the front controller.
     * 
     * @see    AbstractAction::execute()
     * @return void
     */
    public function execute()
    {
        parent::execute();

        $obj = null ;
        $dao = DAOFactory::getDAO($this->_objectType);
        if ($this->_id != null) {
            $obj = $dao->retrieveByPk($this->_id);
        }

        $typeId = $this->_request->getParameter("id_type");

        $this->_response->setAttribute("object", $obj);
        $this->_response->setAttribute("typeId", $typeId);

        $this->findForward(strtolower($this->_objectType));
    }
}
